﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using TJADRICD.Model;

namespace TJADRICD.DLL
{
   public class ProjectInformationDll
    {
       private string tableName="project";

       //获取项目有关的信心，传递地的参数为项目编号pn和子项目编号spn
        public ProjectInformation getProjectInformation(string pn,string spn)
        {
            string selectStr = "select * from " + tableName+" where pn="+pn+" and spn="+spn;
            try
            {
                SqlConnection conn = Connection.getSqlConnection(CONST.connstr);
                SqlCommand cmd = new SqlCommand(selectStr, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    ProjectInformation projectInformation = new ProjectInformation();
                    projectInformation.CCSC =reader["ccsc"].ToString();
                    projectInformation.CCE = reader["cce"].ToString();
                    projectInformation.PNSC = reader["pnsc"].ToString();
                    projectInformation.PNE = reader["pne"].ToString();
                    projectInformation.SPNSC = reader["spnsc"].ToString();
                    projectInformation.SPNE = reader["spne"].ToString();
                    projectInformation.PN = reader["pn"].ToString();
                    projectInformation.SPN = reader["spn"].ToString();
                   conn.Close();
                   reader.Close();
                    return projectInformation;
                }
                conn.Close();
                reader.Close();
                return null;
            }
            catch (Exception e)
            {
                Console.WriteLine("获取数据库信息时候发生了错误：" + e.Message);
                return null;
            }
        }
    }
}
